package com.xy.biz.rs.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.rs.domain.req.GetByProductDictCodeRequest;
import com.xy.biz.rs.domain.req.UpdateTechniqueRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.rs.domain.bo.TechniqueBO;
import com.xy.biz.rs.domain.po.TechniquePO;
import com.xy.biz.rs.domain.query.TechniqueQuery;
import com.xy.biz.rs.domain.resp.GetTechniqueResponse;
import com.xy.biz.rs.domain.req.SaveTechniqueRequest;
import com.xy.biz.rs.domain.req.ListTechniqueRequest;

/**
 *
 *
 * @author wwj
 * @date 2021-4-13
 */
public class TechniqueConverter {

	public static TechniquePO toPO(TechniqueBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TechniquePO(), true);
	}

	public static List<TechniquePO> toPO(Collection<TechniqueBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TechniquePO(), true);
	}

	public static TechniqueBO fromPO(TechniquePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TechniqueBO());
	}

	public static List<TechniqueBO> fromPO(Collection<TechniquePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TechniqueBO());
	}

	public static TechniqueBO toBO(SaveTechniqueRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new TechniqueBO(), true);
	}

	public static TechniqueBO toBO(GetByProductDictCodeRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new TechniqueBO(), true);
	}

	public static TechniqueBO toBO(UpdateTechniqueRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new TechniqueBO(), true);
	}

	public static List<TechniqueBO> toBO(Collection<SaveTechniqueRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TechniqueBO(), true);
	}

	public static GetTechniqueResponse toResponse(TechniqueBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetTechniqueResponse());
	}

	public static List<GetTechniqueResponse> toResponse(Collection<TechniqueBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetTechniqueResponse());
	}

	public static TechniqueQuery toQuery(ListTechniqueRequest source) {
		if(null == source) {
			return null;
		}
		TechniqueQuery target = new TechniqueQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
